#include "FileUtility.h"

bool PutFileContent(const char* pszFileName,char* pData,unsigned int dwDataLen)
{
	FILE* fp = fopen(pszFileName,"wb");
	if (fp==NULL) {
		return false;
	}
	unsigned int dwWrited = fwrite(pData,1,dwDataLen,fp);
	fclose(fp);
	return (dwDataLen == dwWrited);
}

bool GetFileContent(const char* pszFileName,char* pData,unsigned int DwDataLen)
{
	FILE* fp = fopen(pszFileName,"rb");
	if (fp==NULL) {
		return false;
	}
	unsigned int dwReaded = fread(pData,1,DwDataLen,fp);
	fclose(fp);
	if (DwDataLen == dwReaded) {
		return true;
	}
	return false;
}

long GetLocalFileSize(const char* pszFileName)
{
	struct stat f_stat;
	if (stat(pszFileName, &f_stat) == -1) {
		return -1;
	}
	return (long)f_stat.st_size;
}